Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
b084bc28
Commit
b084bc28
authored
Oct 08, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use the "bool" data type instead of "int"
"bool" should be used in C99 programs for boolean values.
parent
71351160
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
74 additions
and
65 deletions
+74
-65
audio.c
src/audio.c
+2
-1
audio.h
src/audio.h
+2
-1
audio_format.h
src/audio_format.h
+4
-3
decoder_api.c
src/decoder_api.c
+1
-1
decoder_api.h
src/decoder_api.h
+4
-3
decoder_internal.h
src/decoder_internal.h
+1
-1
decoder_thread.c
src/decoder_thread.c
+3
-3
flac_plugin.c
src/inputPlugins/flac_plugin.c
+2
-2
mp4_plugin.c
src/inputPlugins/mp4_plugin.c
+7
-7
oggflac_plugin.c
src/inputPlugins/oggflac_plugin.c
+3
-3
oggvorbis_plugin.c
src/inputPlugins/oggvorbis_plugin.c
+3
-3
wavpack_plugin.c
src/inputPlugins/wavpack_plugin.c
+3
-3
notify.c
src/notify.c
+3
-3
notify.h
src/notify.h
+2
-1
outputBuffer.c
src/outputBuffer.c
+2
-2
outputBuffer.h
src/outputBuffer.h
+3
-2
player_thread.c
src/player_thread.c
+4
-4
playlist.c
src/playlist.c
+13
-13
playlist.h
src/playlist.h
+8
-7
song.h
src/song.h
+4
-2
No files found.
src/audio.c
View file @
b084bc28
...
@@ -204,7 +204,8 @@ void finishAudioDriver(void)
...
@@ -204,7 +204,8 @@ void finishAudioDriver(void)
audioOutputArraySize
=
0
;
audioOutputArraySize
=
0
;
}
}
int
isCurrentAudioFormat
(
const
struct
audio_format
*
audioFormat
)
bool
isCurrentAudioFormat
(
const
struct
audio_format
*
audioFormat
)
{
{
assert
(
audioFormat
!=
NULL
);
assert
(
audioFormat
!=
NULL
);
...
...
src/audio.h
View file @
b084bc28
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#ifndef AUDIO_H
#ifndef AUDIO_H
#define AUDIO_H
#define AUDIO_H
#include <stdbool.h>
#include <stdio.h>
#include <stdio.h>
#define AUDIO_AO_DRIVER_DEFAULT "default"
#define AUDIO_AO_DRIVER_DEFAULT "default"
...
@@ -51,7 +52,7 @@ void dropBufferedAudio(void);
...
@@ -51,7 +52,7 @@ void dropBufferedAudio(void);
void
closeAudioDevice
(
void
);
void
closeAudioDevice
(
void
);
int
isCurrentAudioFormat
(
const
struct
audio_format
*
audioFormat
);
bool
isCurrentAudioFormat
(
const
struct
audio_format
*
audioFormat
);
void
sendMetadataToAudioDevice
(
const
struct
tag
*
tag
);
void
sendMetadataToAudioDevice
(
const
struct
tag
*
tag
);
...
...
src/audio_format.h
View file @
b084bc28
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#define AUDIO_FORMAT_H
#define AUDIO_FORMAT_H
#include <stdint.h>
#include <stdint.h>
#include <stdbool.h>
struct
audio_format
{
struct
audio_format
{
uint32_t
sampleRate
;
uint32_t
sampleRate
;
...
@@ -34,13 +35,13 @@ static inline void audio_format_clear(struct audio_format *af)
...
@@ -34,13 +35,13 @@ static inline void audio_format_clear(struct audio_format *af)
af
->
channels
=
0
;
af
->
channels
=
0
;
}
}
static
inline
int
audio_format_defined
(
const
struct
audio_format
*
af
)
static
inline
bool
audio_format_defined
(
const
struct
audio_format
*
af
)
{
{
return
af
->
sampleRate
!=
0
;
return
af
->
sampleRate
!=
0
;
}
}
static
inline
int
audio_format_equals
(
const
struct
audio_format
*
a
,
static
inline
bool
audio_format_equals
(
const
struct
audio_format
*
a
,
const
struct
audio_format
*
b
)
const
struct
audio_format
*
b
)
{
{
return
a
->
sampleRate
==
b
->
sampleRate
&&
return
a
->
sampleRate
==
b
->
sampleRate
&&
a
->
bits
==
b
->
bits
&&
a
->
bits
==
b
->
bits
&&
...
...
src/decoder_api.c
View file @
b084bc28
...
@@ -85,7 +85,7 @@ double decoder_seek_where(mpd_unused struct decoder * decoder)
...
@@ -85,7 +85,7 @@ double decoder_seek_where(mpd_unused struct decoder * decoder)
{
{
assert
(
dc
.
command
==
DECODE_COMMAND_SEEK
);
assert
(
dc
.
command
==
DECODE_COMMAND_SEEK
);
decoder
->
seeking
=
1
;
decoder
->
seeking
=
true
;
return
dc
.
seekWhere
;
return
dc
.
seekWhere
;
}
}
...
...
src/decoder_api.h
View file @
b084bc28
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include "audio_format.h"
#include "audio_format.h"
#include "playerData.h"
#include "playerData.h"
#include <stdbool.h>
/* valid values for streamTypes in the InputPlugin struct: */
/* valid values for streamTypes in the InputPlugin struct: */
#define INPUT_PLUGIN_STREAM_FILE 0x01
#define INPUT_PLUGIN_STREAM_FILE 0x01
...
@@ -65,10 +66,10 @@ struct decoder_plugin {
...
@@ -65,10 +66,10 @@ struct decoder_plugin {
void
(
*
finish
)(
void
);
void
(
*
finish
)(
void
);
/**
/**
*
boolean return value, returns 1 if the InputStream is
*
returns true if the InputStream is decodable by the
*
decodable by the InputPlugin, 0
if not
*
InputPlugin, false
if not
*/
*/
unsigned
int
(
*
try_decode
)(
InputStream
*
);
bool
(
*
try_decode
)(
InputStream
*
);
/**
/**
* this will be used to decode InputStreams, and is
* this will be used to decode InputStreams, and is
...
...
src/decoder_internal.h
View file @
b084bc28
...
@@ -27,7 +27,7 @@ struct decoder {
...
@@ -27,7 +27,7 @@ struct decoder {
ConvState
conv_state
;
ConvState
conv_state
;
int
seeking
;
bool
seeking
;
};
};
#endif
#endif
src/decoder_thread.c
View file @
b084bc28
...
@@ -31,7 +31,7 @@ static void decodeStart(void)
...
@@ -31,7 +31,7 @@ static void decodeStart(void)
{
{
struct
decoder
decoder
;
struct
decoder
decoder
;
int
ret
;
int
ret
;
int
close_instream
=
1
;
bool
close_instream
=
true
;
InputStream
inStream
;
InputStream
inStream
;
struct
decoder_plugin
*
plugin
=
NULL
;
struct
decoder_plugin
*
plugin
=
NULL
;
char
path_max_fs
[
MPD_PATH_MAX
];
char
path_max_fs
[
MPD_PATH_MAX
];
...
@@ -53,7 +53,7 @@ static void decodeStart(void)
...
@@ -53,7 +53,7 @@ static void decodeStart(void)
goto
stop_no_close
;
goto
stop_no_close
;
}
}
decoder
.
seeking
=
0
;
decoder
.
seeking
=
false
;
dc
.
state
=
DECODE_STATE_START
;
dc
.
state
=
DECODE_STATE_START
;
dc
.
command
=
DECODE_COMMAND_NONE
;
dc
.
command
=
DECODE_COMMAND_NONE
;
...
@@ -137,7 +137,7 @@ static void decodeStart(void)
...
@@ -137,7 +137,7 @@ static void decodeStart(void)
if
(
plugin
->
file_decode
!=
NULL
)
{
if
(
plugin
->
file_decode
!=
NULL
)
{
closeInputStream
(
&
inStream
);
closeInputStream
(
&
inStream
);
close_instream
=
0
;
close_instream
=
false
;
decoder
.
plugin
=
plugin
;
decoder
.
plugin
=
plugin
;
ret
=
plugin
->
file_decode
(
&
decoder
,
ret
=
plugin
->
file_decode
(
&
decoder
,
path_max_fs
);
path_max_fs
);
...
...
src/inputPlugins/flac_plugin.c
View file @
b084bc28
...
@@ -427,9 +427,9 @@ static int oggflac_decode(struct decoder *decoder, InputStream * inStream)
...
@@ -427,9 +427,9 @@ static int oggflac_decode(struct decoder *decoder, InputStream * inStream)
return
flac_decode_internal
(
decoder
,
inStream
,
1
);
return
flac_decode_internal
(
decoder
,
inStream
,
1
);
}
}
static
unsigned
int
oggflac_try_decode
(
InputStream
*
inStream
)
static
bool
oggflac_try_decode
(
InputStream
*
inStream
)
{
{
return
(
ogg_stream_type_detect
(
inStream
)
==
FLAC
)
?
1
:
0
;
return
ogg_stream_type_detect
(
inStream
)
==
FLAC
;
}
}
static
const
char
*
oggflac_suffixes
[]
=
{
"ogg"
,
"oga"
,
NULL
};
static
const
char
*
oggflac_suffixes
[]
=
{
"ogg"
,
"oga"
,
NULL
};
...
...
src/inputPlugins/mp4_plugin.c
View file @
b084bc28
...
@@ -103,12 +103,12 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
...
@@ -103,12 +103,12 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
unsigned
int
initial
=
1
;
unsigned
int
initial
=
1
;
float
*
seekTable
;
float
*
seekTable
;
long
seekTableEnd
=
-
1
;
long
seekTableEnd
=
-
1
;
int
seekPositionFound
=
0
;
bool
seekPositionFound
=
false
;
long
offset
;
long
offset
;
uint16_t
bitRate
=
0
;
uint16_t
bitRate
=
0
;
int
seeking
=
0
;
bool
seeking
=
false
;
double
seek_where
=
0
;
double
seek_where
=
0
;
int
initialized
=
0
;
bool
initialized
=
false
;
mp4cb
=
xmalloc
(
sizeof
(
mp4ff_callback_t
));
mp4cb
=
xmalloc
(
sizeof
(
mp4ff_callback_t
));
mp4cb
->
read
=
mp4_inputStreamReadCallback
;
mp4cb
->
read
=
mp4_inputStreamReadCallback
;
...
@@ -189,7 +189,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
...
@@ -189,7 +189,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
for
(
sampleId
=
0
;
sampleId
<
numSamples
;
sampleId
++
)
{
for
(
sampleId
=
0
;
sampleId
<
numSamples
;
sampleId
++
)
{
if
(
decoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
)
{
if
(
decoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
)
{
seeking
=
1
;
seeking
=
true
;
seek_where
=
decoder_seek_where
(
mpd_decoder
);
seek_where
=
decoder_seek_where
(
mpd_decoder
);
}
}
...
@@ -219,10 +219,10 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
...
@@ -219,10 +219,10 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
file_time
+=
((
float
)
dur
)
/
scale
;
file_time
+=
((
float
)
dur
)
/
scale
;
if
(
seeking
&&
file_time
>
seek_where
)
if
(
seeking
&&
file_time
>
seek_where
)
seekPositionFound
=
1
;
seekPositionFound
=
true
;
if
(
seeking
&&
seekPositionFound
)
{
if
(
seeking
&&
seekPositionFound
)
{
seekPositionFound
=
0
;
seekPositionFound
=
false
;
decoder_clear
(
mpd_decoder
);
decoder_clear
(
mpd_decoder
);
seeking
=
0
;
seeking
=
0
;
decoder_command_finished
(
mpd_decoder
);
decoder_command_finished
(
mpd_decoder
);
...
@@ -259,7 +259,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
...
@@ -259,7 +259,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
audio_format
.
channels
=
frameInfo
.
channels
;
audio_format
.
channels
=
frameInfo
.
channels
;
decoder_initialized
(
mpd_decoder
,
&
audio_format
,
decoder_initialized
(
mpd_decoder
,
&
audio_format
,
total_time
);
total_time
);
initialized
=
1
;
initialized
=
true
;
}
}
if
(
channels
*
(
unsigned
long
)(
dur
+
offset
)
>
frameInfo
.
samples
)
{
if
(
channels
*
(
unsigned
long
)(
dur
+
offset
)
>
frameInfo
.
samples
)
{
...
...
src/inputPlugins/oggflac_plugin.c
View file @
b084bc28
...
@@ -283,14 +283,14 @@ static struct tag *oggflac_TagDup(char *file)
...
@@ -283,14 +283,14 @@ static struct tag *oggflac_TagDup(char *file)
return
data
.
tag
;
return
data
.
tag
;
}
}
static
unsigned
int
oggflac_try_decode
(
InputStream
*
inStream
)
static
bool
oggflac_try_decode
(
InputStream
*
inStream
)
{
{
if
(
!
inStream
->
seekable
)
if
(
!
inStream
->
seekable
)
/* we cannot seek after the detection, so don't bother
/* we cannot seek after the detection, so don't bother
checking */
checking */
return
1
;
return
true
;
return
(
ogg_stream_type_detect
(
inStream
)
==
FLAC
)
?
1
:
0
;
return
ogg_stream_type_detect
(
inStream
)
==
FLAC
;
}
}
static
int
oggflac_decode
(
struct
decoder
*
mpd_decoder
,
InputStream
*
inStream
)
static
int
oggflac_decode
(
struct
decoder
*
mpd_decoder
,
InputStream
*
inStream
)
...
...
src/inputPlugins/oggvorbis_plugin.c
View file @
b084bc28
...
@@ -365,14 +365,14 @@ static struct tag *oggvorbis_TagDup(char *file)
...
@@ -365,14 +365,14 @@ static struct tag *oggvorbis_TagDup(char *file)
return
ret
;
return
ret
;
}
}
static
unsigned
int
oggvorbis_try_decode
(
InputStream
*
inStream
)
static
bool
oggvorbis_try_decode
(
InputStream
*
inStream
)
{
{
if
(
!
inStream
->
seekable
)
if
(
!
inStream
->
seekable
)
/* we cannot seek after the detection, so don't bother
/* we cannot seek after the detection, so don't bother
checking */
checking */
return
1
;
return
true
;
return
(
ogg_stream_type_detect
(
inStream
)
==
VORBIS
)
?
1
:
0
;
return
ogg_stream_type_detect
(
inStream
)
==
VORBIS
;
}
}
static
const
char
*
oggvorbis_Suffixes
[]
=
{
"ogg"
,
"oga"
,
NULL
};
static
const
char
*
oggvorbis_Suffixes
[]
=
{
"ogg"
,
"oga"
,
NULL
};
...
...
src/inputPlugins/wavpack_plugin.c
View file @
b084bc28
...
@@ -417,7 +417,7 @@ initInputStreamPlus(InputStreamPlus *isp, struct decoder *decoder,
...
@@ -417,7 +417,7 @@ initInputStreamPlus(InputStreamPlus *isp, struct decoder *decoder,
/*
/*
* Tries to decode the specified stream, and gives true if managed to do it.
* Tries to decode the specified stream, and gives true if managed to do it.
*/
*/
static
unsigned
int
wavpack_trydecode
(
InputStream
*
is
)
static
bool
wavpack_trydecode
(
InputStream
*
is
)
{
{
char
error
[
ERRORLEN
];
char
error
[
ERRORLEN
];
WavpackContext
*
wpc
;
WavpackContext
*
wpc
;
...
@@ -427,13 +427,13 @@ static unsigned int wavpack_trydecode(InputStream *is)
...
@@ -427,13 +427,13 @@ static unsigned int wavpack_trydecode(InputStream *is)
wpc
=
WavpackOpenFileInputEx
(
&
mpd_is_reader
,
&
isp
,
NULL
,
error
,
wpc
=
WavpackOpenFileInputEx
(
&
mpd_is_reader
,
&
isp
,
NULL
,
error
,
OPEN_STREAMING
,
0
);
OPEN_STREAMING
,
0
);
if
(
wpc
==
NULL
)
if
(
wpc
==
NULL
)
return
0
;
return
false
;
WavpackCloseFile
(
wpc
);
WavpackCloseFile
(
wpc
);
/* Seek it back in order to play from the first byte. */
/* Seek it back in order to play from the first byte. */
seekInputStream
(
is
,
0
,
SEEK_SET
);
seekInputStream
(
is
,
0
,
SEEK_SET
);
return
1
;
return
true
;
}
}
static
int
wavpack_open_wvc
(
struct
decoder
*
decoder
,
static
int
wavpack_open_wvc
(
struct
decoder
*
decoder
,
...
...
src/notify.c
View file @
b084bc28
...
@@ -31,7 +31,7 @@ void notify_init(struct notify *notify)
...
@@ -31,7 +31,7 @@ void notify_init(struct notify *notify)
if
(
ret
!=
0
)
if
(
ret
!=
0
)
FATAL
(
"pthread_mutex_init() failed"
);
FATAL
(
"pthread_mutex_init() failed"
);
notify
->
pending
=
0
;
notify
->
pending
=
false
;
}
}
void
notify_deinit
(
struct
notify
*
notify
)
void
notify_deinit
(
struct
notify
*
notify
)
...
@@ -45,14 +45,14 @@ void notify_wait(struct notify *notify)
...
@@ -45,14 +45,14 @@ void notify_wait(struct notify *notify)
pthread_mutex_lock
(
&
notify
->
mutex
);
pthread_mutex_lock
(
&
notify
->
mutex
);
while
(
!
notify
->
pending
)
while
(
!
notify
->
pending
)
pthread_cond_wait
(
&
notify
->
cond
,
&
notify
->
mutex
);
pthread_cond_wait
(
&
notify
->
cond
,
&
notify
->
mutex
);
notify
->
pending
=
0
;
notify
->
pending
=
false
;
pthread_mutex_unlock
(
&
notify
->
mutex
);
pthread_mutex_unlock
(
&
notify
->
mutex
);
}
}
void
notify_signal
(
struct
notify
*
notify
)
void
notify_signal
(
struct
notify
*
notify
)
{
{
pthread_mutex_lock
(
&
notify
->
mutex
);
pthread_mutex_lock
(
&
notify
->
mutex
);
notify
->
pending
=
1
;
notify
->
pending
=
true
;
pthread_cond_signal
(
&
notify
->
cond
);
pthread_cond_signal
(
&
notify
->
cond
);
pthread_mutex_unlock
(
&
notify
->
mutex
);
pthread_mutex_unlock
(
&
notify
->
mutex
);
}
}
src/notify.h
View file @
b084bc28
...
@@ -19,12 +19,13 @@
...
@@ -19,12 +19,13 @@
#ifndef NOTIFY_H
#ifndef NOTIFY_H
#define NOTIFY_H
#define NOTIFY_H
#include <stdbool.h>
#include <pthread.h>
#include <pthread.h>
struct
notify
{
struct
notify
{
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
pthread_cond_t
cond
;
pthread_cond_t
cond
;
int
pending
;
bool
pending
;
};
};
#define NOTIFY_INITIALIZER { \
#define NOTIFY_INITIALIZER { \
...
...
src/outputBuffer.c
View file @
b084bc28
...
@@ -34,7 +34,7 @@ ob_init(unsigned int size, struct notify *notify)
...
@@ -34,7 +34,7 @@ ob_init(unsigned int size, struct notify *notify)
ob
.
size
=
size
;
ob
.
size
=
size
;
ob
.
begin
=
0
;
ob
.
begin
=
0
;
ob
.
end
=
0
;
ob
.
end
=
0
;
ob
.
lazy
=
0
;
ob
.
lazy
=
false
;
ob
.
notify
=
notify
;
ob
.
notify
=
notify
;
ob
.
chunks
[
0
].
chunkSize
=
0
;
ob
.
chunks
[
0
].
chunkSize
=
0
;
}
}
...
@@ -96,7 +96,7 @@ void ob_flush(void)
...
@@ -96,7 +96,7 @@ void ob_flush(void)
}
}
}
}
void
ob_set_lazy
(
int
lazy
)
void
ob_set_lazy
(
bool
lazy
)
{
{
ob
.
lazy
=
lazy
;
ob
.
lazy
=
lazy
;
}
}
...
...
src/outputBuffer.h
View file @
b084bc28
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "audio_format.h"
#include "audio_format.h"
#include <stddef.h>
#include <stddef.h>
#include <stdbool.h>
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
#define CHUNK_SIZE 1020
#define CHUNK_SIZE 1020
...
@@ -50,7 +51,7 @@ struct output_buffer {
...
@@ -50,7 +51,7 @@ struct output_buffer {
/** non-zero if the player thread should only we woken up if
/** non-zero if the player thread should only we woken up if
the buffer becomes non-empty */
the buffer becomes non-empty */
int
lazy
;
bool
lazy
;
struct
audio_format
audioFormat
;
struct
audio_format
audioFormat
;
...
@@ -74,7 +75,7 @@ void ob_flush(void);
...
@@ -74,7 +75,7 @@ void ob_flush(void);
* previously empty, i.e. when the player thread has really been
* previously empty, i.e. when the player thread has really been
* waiting for us.
* waiting for us.
*/
*/
void
ob_set_lazy
(
int
lazy
);
void
ob_set_lazy
(
bool
lazy
);
/** is the buffer empty? */
/** is the buffer empty? */
int
ob_is_empty
(
void
);
int
ob_is_empty
(
void
);
...
...
src/player_thread.c
View file @
b084bc28
...
@@ -192,7 +192,7 @@ static void do_play(void)
...
@@ -192,7 +192,7 @@ static void do_play(void)
int
next
=
-
1
;
int
next
=
-
1
;
ob_clear
();
ob_clear
();
ob_set_lazy
(
0
);
ob_set_lazy
(
false
);
dc_start
(
&
pc
.
notify
,
pc
.
next_song
);
dc_start
(
&
pc
.
notify
,
pc
.
next_song
);
if
(
waitOnDecode
(
&
decodeWaitedOn
)
<
0
)
{
if
(
waitOnDecode
(
&
decodeWaitedOn
)
<
0
)
{
...
@@ -222,7 +222,7 @@ static void do_play(void)
...
@@ -222,7 +222,7 @@ static void do_play(void)
}
else
{
}
else
{
/* buffering is complete */
/* buffering is complete */
buffering
=
0
;
buffering
=
0
;
ob_set_lazy
(
1
);
ob_set_lazy
(
true
);
}
}
}
}
...
@@ -314,7 +314,7 @@ static void do_play(void)
...
@@ -314,7 +314,7 @@ static void do_play(void)
}
}
nextChunk
=
ob_absolute
(
crossFadeChunks
);
nextChunk
=
ob_absolute
(
crossFadeChunks
);
if
(
nextChunk
>=
0
)
{
if
(
nextChunk
>=
0
)
{
ob_set_lazy
(
1
);
ob_set_lazy
(
true
);
cross_fade_apply
(
beginChunk
,
cross_fade_apply
(
beginChunk
,
ob_get_chunk
(
nextChunk
),
ob_get_chunk
(
nextChunk
),
&
(
ob
.
audioFormat
),
&
(
ob
.
audioFormat
),
...
@@ -331,7 +331,7 @@ static void do_play(void)
...
@@ -331,7 +331,7 @@ static void do_play(void)
}
else
{
}
else
{
/* wait for the
/* wait for the
decoder */
decoder */
ob_set_lazy
(
0
);
ob_set_lazy
(
false
);
notify_wait
(
&
pc
.
notify
);
notify_wait
(
&
pc
.
notify
);
continue
;
continue
;
}
}
...
...
src/playlist.c
View file @
b084bc28
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
#define PLAYLIST_HASH_MULT 4
#define PLAYLIST_HASH_MULT 4
#define DEFAULT_PLAYLIST_MAX_LENGTH (1024*16)
#define DEFAULT_PLAYLIST_MAX_LENGTH (1024*16)
#define DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS
0
#define DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS
false
static
Playlist
playlist
;
static
Playlist
playlist
;
static
int
playlist_state
=
PLAYLIST_STATE_STOP
;
static
int
playlist_state
=
PLAYLIST_STATE_STOP
;
...
@@ -66,7 +66,7 @@ static int playlist_stopOnError;
...
@@ -66,7 +66,7 @@ static int playlist_stopOnError;
static
int
playlist_errorCount
;
static
int
playlist_errorCount
;
static
int
playlist_noGoToNext
;
static
int
playlist_noGoToNext
;
int
playlist_saveAbsolutePaths
=
DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS
;
bool
playlist_saveAbsolutePaths
=
DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS
;
static
void
swapOrder
(
int
a
,
int
b
);
static
void
swapOrder
(
int
a
,
int
b
);
static
void
playPlaylistOrderNumber
(
int
orderNum
);
static
void
playPlaylistOrderNumber
(
int
orderNum
);
...
@@ -119,9 +119,9 @@ void initPlaylist(void)
...
@@ -119,9 +119,9 @@ void initPlaylist(void)
ConfigParam
*
param
;
ConfigParam
*
param
;
playlist
.
length
=
0
;
playlist
.
length
=
0
;
playlist
.
repeat
=
0
;
playlist
.
repeat
=
false
;
playlist
.
version
=
1
;
playlist
.
version
=
1
;
playlist
.
random
=
0
;
playlist
.
random
=
false
;
playlist
.
queued
=
-
1
;
playlist
.
queued
=
-
1
;
playlist
.
current
=
-
1
;
playlist
.
current
=
-
1
;
...
@@ -329,9 +329,9 @@ void readPlaylistState(FILE *fp)
...
@@ -329,9 +329,9 @@ void readPlaylistState(FILE *fp)
if
(
strcmp
if
(
strcmp
(
&
(
buffer
[
strlen
(
PLAYLIST_STATE_FILE_REPEAT
)]),
(
&
(
buffer
[
strlen
(
PLAYLIST_STATE_FILE_REPEAT
)]),
"1"
)
==
0
)
{
"1"
)
==
0
)
{
setPlaylistRepeatStatus
(
1
);
setPlaylistRepeatStatus
(
true
);
}
else
}
else
setPlaylistRepeatStatus
(
0
);
setPlaylistRepeatStatus
(
false
);
}
else
if
(
!
prefixcmp
(
buffer
,
PLAYLIST_STATE_FILE_CROSSFADE
))
{
}
else
if
(
!
prefixcmp
(
buffer
,
PLAYLIST_STATE_FILE_CROSSFADE
))
{
setPlayerCrossFade
(
atoi
setPlayerCrossFade
(
atoi
(
&
(
&
...
@@ -344,9 +344,9 @@ void readPlaylistState(FILE *fp)
...
@@ -344,9 +344,9 @@ void readPlaylistState(FILE *fp)
(
buffer
(
buffer
[
strlen
(
PLAYLIST_STATE_FILE_RANDOM
)]),
[
strlen
(
PLAYLIST_STATE_FILE_RANDOM
)]),
"1"
)
==
0
)
{
"1"
)
==
0
)
{
setPlaylistRandomStatus
(
1
);
setPlaylistRandomStatus
(
true
);
}
else
}
else
setPlaylistRandomStatus
(
0
);
setPlaylistRandomStatus
(
false
);
}
else
if
(
!
prefixcmp
(
buffer
,
PLAYLIST_STATE_FILE_CURRENT
))
{
}
else
if
(
!
prefixcmp
(
buffer
,
PLAYLIST_STATE_FILE_CURRENT
))
{
if
(
strlen
(
buffer
)
==
if
(
strlen
(
buffer
)
==
strlen
(
PLAYLIST_STATE_FILE_CURRENT
))
strlen
(
PLAYLIST_STATE_FILE_CURRENT
))
...
@@ -980,17 +980,17 @@ void playPlaylistIfPlayerStopped(void)
...
@@ -980,17 +980,17 @@ void playPlaylistIfPlayerStopped(void)
}
}
}
}
int
getPlaylistRepeatStatus
(
void
)
bool
getPlaylistRepeatStatus
(
void
)
{
{
return
playlist
.
repeat
;
return
playlist
.
repeat
;
}
}
int
getPlaylistRandomStatus
(
void
)
bool
getPlaylistRandomStatus
(
void
)
{
{
return
playlist
.
random
;
return
playlist
.
random
;
}
}
void
setPlaylistRepeatStatus
(
int
status
)
void
setPlaylistRepeatStatus
(
bool
status
)
{
{
if
(
playlist_state
==
PLAYLIST_STATE_PLAY
)
{
if
(
playlist_state
==
PLAYLIST_STATE_PLAY
)
{
if
(
playlist
.
repeat
&&
!
status
&&
playlist
.
queued
==
0
)
if
(
playlist
.
repeat
&&
!
status
&&
playlist
.
queued
==
0
)
...
@@ -1150,9 +1150,9 @@ static void randomizeOrder(int start, int end)
...
@@ -1150,9 +1150,9 @@ static void randomizeOrder(int start, int end)
}
}
}
}
void
setPlaylistRandomStatus
(
int
status
)
void
setPlaylistRandomStatus
(
bool
status
)
{
{
int
statusWas
=
playlist
.
random
;
bool
statusWas
=
playlist
.
random
;
playlist
.
random
=
status
;
playlist
.
random
=
status
;
...
...
src/playlist.h
View file @
b084bc28
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "locate.h"
#include "locate.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdio.h>
#define PLAYLIST_FILE_SUFFIX "m3u"
#define PLAYLIST_FILE_SUFFIX "m3u"
...
@@ -50,12 +51,12 @@ typedef struct _Playlist {
...
@@ -50,12 +51,12 @@ typedef struct _Playlist {
int
length
;
int
length
;
int
current
;
int
current
;
int
queued
;
int
queued
;
int
repeat
;
bool
repeat
;
int
random
;
bool
random
;
uint32_t
version
;
uint32_t
version
;
}
Playlist
;
}
Playlist
;
extern
int
playlist_saveAbsolutePaths
;
extern
bool
playlist_saveAbsolutePaths
;
extern
int
playlist_max_length
;
extern
int
playlist_max_length
;
...
@@ -119,13 +120,13 @@ enum playlist_result swapSongsInPlaylistById(int id1, int id2);
...
@@ -119,13 +120,13 @@ enum playlist_result swapSongsInPlaylistById(int id1, int id2);
enum
playlist_result
loadPlaylist
(
struct
client
*
client
,
const
char
*
utf8file
);
enum
playlist_result
loadPlaylist
(
struct
client
*
client
,
const
char
*
utf8file
);
int
getPlaylistRepeatStatus
(
void
);
bool
getPlaylistRepeatStatus
(
void
);
void
setPlaylistRepeatStatus
(
int
status
);
void
setPlaylistRepeatStatus
(
bool
status
);
int
getPlaylistRandomStatus
(
void
);
bool
getPlaylistRandomStatus
(
void
);
void
setPlaylistRandomStatus
(
int
status
);
void
setPlaylistRandomStatus
(
bool
status
);
int
getPlaylistCurrentSong
(
void
);
int
getPlaylistCurrentSong
(
void
);
...
...
src/song.h
View file @
b084bc28
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
#ifndef SONG_H
#ifndef SONG_H
#define SONG_H
#define SONG_H
#include <stddef.h>
#include <stdbool.h>
#include <sys/time.h>
#include <sys/time.h>
#define SONG_BEGIN "songList begin"
#define SONG_BEGIN "songList begin"
...
@@ -55,10 +57,10 @@ updateSongInfo(struct song *song);
...
@@ -55,10 +57,10 @@ updateSongInfo(struct song *song);
char
*
char
*
get_song_url
(
char
*
path_max_tmp
,
struct
song
*
song
);
get_song_url
(
char
*
path_max_tmp
,
struct
song
*
song
);
static
inline
int
static
inline
bool
song_is_file
(
const
struct
song
*
song
)
song_is_file
(
const
struct
song
*
song
)
{
{
return
!!
song
->
parentDir
;
return
song
->
parentDir
!=
NULL
;
}
}
#endif
#endif
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