Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
fb9c11df
Commit
fb9c11df
authored
Apr 25, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(src/components/sound-player/SoundPlayer): handle eof
parent
b4739025
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
99 additions
and
9 deletions
+99
-9
resources.qrc
linphone-desktop/resources.qrc
+1
-0
CoreManager.cpp
linphone-desktop/src/components/core/CoreManager.cpp
+3
-1
SoundPlayer.cpp
linphone-desktop/src/components/sound-player/SoundPlayer.cpp
+35
-2
SoundPlayer.hpp
linphone-desktop/src/components/sound-player/SoundPlayer.hpp
+15
-5
SettingsAudio.qml
linphone-desktop/ui/views/App/Settings/SettingsAudio.qml
+34
-1
SettingsAudioStyle.qml
...sktop/ui/views/App/Styles/Settings/SettingsAudioStyle.qml
+10
-0
qmldir
linphone-desktop/ui/views/App/Styles/qmldir
+1
-0
No files found.
linphone-desktop/resources.qrc
View file @
fb9c11df
...
...
@@ -401,6 +401,7 @@
<file>
ui/views/App/Styles/Main/MainWindowStyle.qml
</file>
<file>
ui/views/App/Styles/Main/ManageAccountsStyle.qml
</file>
<file>
ui/views/App/Styles/qmldir
</file>
<file>
ui/views/App/Styles/Settings/SettingsAudioStyle.qml
</file>
<file>
ui/views/App/Styles/Settings/SettingsSipAccountsEditStyle.qml
</file>
<file>
ui/views/App/Styles/Settings/SettingsVideoPreviewStyle.qml
</file>
<file>
ui/views/App/Styles/Settings/SettingsWindowStyle.qml
</file>
...
...
linphone-desktop/src/components/core/CoreManager.cpp
View file @
fb9c11df
...
...
@@ -29,6 +29,8 @@
#include <QtConcurrent>
#include <QTimer>
#define CBS_CALL_INTERVAL 20
using
namespace
std
;
// =============================================================================
...
...
@@ -66,7 +68,7 @@ void CoreManager::init (QObject *parent, const QString &configPath) {
mInstance
=
new
CoreManager
(
parent
,
configPath
);
QTimer
*
timer
=
mInstance
->
mCbsTimer
=
new
QTimer
(
mInstance
);
timer
->
setInterval
(
20
);
timer
->
setInterval
(
CBS_CALL_INTERVAL
);
QObject
::
connect
(
timer
,
&
QTimer
::
timeout
,
mInstance
,
&
CoreManager
::
iterate
);
}
...
...
linphone-desktop/src/components/sound-player/SoundPlayer.cpp
View file @
fb9c11df
...
...
@@ -20,11 +20,15 @@
* Author: Ronan Abhamon
*/
#include <QTimer>
#include "../../Utils.hpp"
#include "../core/CoreManager.hpp"
#include "SoundPlayer.hpp"
#define FORCE_CLOSE_TIMER_INTERVAL 20
using
namespace
std
;
// =============================================================================
...
...
@@ -37,7 +41,14 @@ public:
private:
void
onEofReached
(
const
shared_ptr
<
linphone
::
Player
>
&
)
override
{
mSoundPlayer
->
stop
();
QMutex
&
mutex
=
mSoundPlayer
->
mForceCloseMutex
;
// Workaround.
// This callback is called in a standard thread of mediastreamer, not a QThread.
// Signals, connect functions, timers... are unavailable.
mutex
.
lock
();
mSoundPlayer
->
mForceClose
=
true
;
mutex
.
unlock
();
}
SoundPlayer
*
mSoundPlayer
;
...
...
@@ -46,6 +57,11 @@ private:
// -----------------------------------------------------------------------------
SoundPlayer
::
SoundPlayer
(
QObject
*
parent
)
:
QObject
(
parent
)
{
mForceCloseTimer
=
new
QTimer
(
this
);
mForceCloseTimer
->
setInterval
(
FORCE_CLOSE_TIMER_INTERVAL
);
QObject
::
connect
(
mForceCloseTimer
,
&
QTimer
::
timeout
,
this
,
&
SoundPlayer
::
handleEof
);
mHandlers
=
make_shared
<
SoundPlayer
::
Handlers
>
(
this
);
mInternalPlayer
=
CoreManager
::
getInstance
()
->
getCore
()
->
createLocalPlayer
(
""
,
""
,
nullptr
);
...
...
@@ -63,6 +79,7 @@ void SoundPlayer::pause () {
return
;
}
mForceCloseTimer
->
stop
();
mPlaybackState
=
SoundPlayer
::
PausedState
;
emit
paused
();
...
...
@@ -87,6 +104,7 @@ void SoundPlayer::play () {
return
;
}
mForceCloseTimer
->
start
();
mPlaybackState
=
SoundPlayer
::
PlayingState
;
emit
playing
();
...
...
@@ -97,9 +115,11 @@ void SoundPlayer::stop () {
if
(
mPlaybackState
==
SoundPlayer
::
StoppedState
)
return
;
m
InternalPlayer
->
close
();
m
ForceCloseTimer
->
stop
();
mPlaybackState
=
SoundPlayer
::
StoppedState
;
mInternalPlayer
->
close
();
emit
stopped
();
emit
playbackStateChanged
(
mPlaybackState
);
}
...
...
@@ -118,6 +138,19 @@ int SoundPlayer::getPosition () const {
// -----------------------------------------------------------------------------
void
SoundPlayer
::
handleEof
()
{
mForceCloseMutex
.
lock
();
if
(
mForceClose
)
{
mForceClose
=
false
;
stop
();
}
mForceCloseMutex
.
unlock
();
}
// -----------------------------------------------------------------------------
void
SoundPlayer
::
setError
(
const
QString
&
message
)
{
qWarning
()
<<
message
;
mInternalPlayer
->
close
();
...
...
linphone-desktop/src/components/sound-player/SoundPlayer.hpp
View file @
fb9c11df
...
...
@@ -25,10 +25,13 @@
#include <memory>
#include <QMutex>
#include <QObject>
// =============================================================================
class
QTimer
;
namespace
linphone
{
class
Player
;
}
...
...
@@ -55,13 +58,13 @@ public:
SoundPlayer
(
QObject
*
parent
=
Q_NULLPTR
);
~
SoundPlayer
()
=
default
;
void
pause
();
void
play
();
void
stop
();
Q_INVOKABLE
void
pause
();
Q_INVOKABLE
void
play
();
Q_INVOKABLE
void
stop
();
void
seek
(
int
offset
);
Q_INVOKABLE
void
seek
(
int
offset
);
int
getPosition
()
const
;
Q_INVOKABLE
int
getPosition
()
const
;
signals:
void
sourceChanged
(
const
QString
&
source
);
...
...
@@ -73,6 +76,8 @@ signals:
void
playbackStateChanged
(
PlaybackState
playbackState
);
private:
void
handleEof
();
void
setError
(
const
QString
&
message
);
QString
getSource
()
const
;
...
...
@@ -86,6 +91,11 @@ private:
QString
mSource
;
PlaybackState
mPlaybackState
=
StoppedState
;
bool
mForceClose
=
false
;
QMutex
mForceCloseMutex
;
QTimer
*
mForceCloseTimer
;
std
::
shared_ptr
<
linphone
::
Player
>
mInternalPlayer
;
std
::
shared_ptr
<
Handlers
>
mHandlers
;
};
...
...
linphone-desktop/ui/views/App/Settings/SettingsAudio.qml
View file @
fb9c11df
...
...
@@ -73,7 +73,40 @@ TabContainer {
FileChooserButton
{
selectedFile
:
SettingsModel
.
ringPath
onAccepted
:
SettingsModel
.
ringPath
=
selectedFile
onAccepted
:
{
ringPlayer
.
stop
()
SettingsModel
.
ringPath
=
selectedFile
}
ActionSwitch
{
anchors
{
left
:
parent
.
right
leftMargin
:
SettingsAudioStyle
.
ringPlayer
.
leftMargin
}
enabled
:
ringPlayer
.
playbackState
===
SoundPlayer
.
PlayingState
icon
:
'
pause
'
onClicked
:
{
if
(
enabled
)
{
ringPlayer
.
stop
()
}
else
{
ringPlayer
.
play
()
}
}
SoundPlayer
{
id
:
ringPlayer
source
:
SettingsModel
.
ringPath
}
Connections
{
target
:
window
onClosing
:
ringPlayer
.
stop
()
}
}
}
}
}
...
...
linphone-desktop/ui/views/App/Styles/Settings/SettingsAudioStyle.qml
0 → 100644
View file @
fb9c11df
pragma
Singleton
import
QtQuick
2.7
// =============================================================================
QtObject
{
property
QtObject
ringPlayer
:
QtObject
{
property
int
leftMargin
:
10
}
}
linphone-desktop/ui/views/App/Styles/qmldir
View file @
fb9c11df
...
...
@@ -25,6 +25,7 @@ singleton MainWindowMenuBarStyle 1.0 Main/MainWindowMenuBarSty
singleton MainWindowStyle 1.0 Main/MainWindowStyle.qml
singleton ManageAccountsStyle 1.0 Main/ManageAccountsStyle.qml
singleton SettingsAudioStyle 1.0 Settings/SettingsAudioStyle.qml
singleton SettingsSipAccountsEditStyle 1.0 Settings/SettingsSipAccountsEditStyle.qml
singleton SettingsVideoPreviewStyle 1.0 Settings/SettingsVideoPreviewStyle.qml
singleton SettingsWindowStyle 1.0 Settings/SettingsWindowStyle.qml
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment