OutputPlugin: pass Tag reference to _send_tag()

This commit is contained in:
Max Kellermann 2014-12-26 22:27:01 +01:00
parent 7077eac589
commit 58a5da33c2
8 changed files with 17 additions and 19 deletions

View File

@ -75,7 +75,7 @@ ao_plugin_delay(AudioOutput *ao)
} }
void void
ao_plugin_send_tag(AudioOutput *ao, const Tag *tag) ao_plugin_send_tag(AudioOutput *ao, const Tag &tag)
{ {
if (ao->plugin.send_tag != nullptr) if (ao->plugin.send_tag != nullptr)
ao->plugin.send_tag(ao, tag); ao->plugin.send_tag(ao, tag);

View File

@ -107,7 +107,7 @@ struct AudioOutputPlugin {
* Display metadata for the next chunk. Optional method, * Display metadata for the next chunk. Optional method,
* because not all devices can display metadata. * because not all devices can display metadata.
*/ */
void (*send_tag)(AudioOutput *data, const Tag *tag); void (*send_tag)(AudioOutput *data, const Tag &tag);
/** /**
* Play a chunk of audio data. * Play a chunk of audio data.
@ -186,7 +186,7 @@ unsigned
ao_plugin_delay(AudioOutput *ao); ao_plugin_delay(AudioOutput *ao);
void void
ao_plugin_send_tag(AudioOutput *ao, const Tag *tag); ao_plugin_send_tag(AudioOutput *ao, const Tag &tag);
size_t size_t
ao_plugin_play(AudioOutput *ao, const void *chunk, size_t size, ao_plugin_play(AudioOutput *ao, const void *chunk, size_t size,

View File

@ -455,7 +455,7 @@ AudioOutput::PlayChunk(const MusicChunk *chunk)
if (tags && gcc_unlikely(chunk->tag != nullptr)) { if (tags && gcc_unlikely(chunk->tag != nullptr)) {
mutex.unlock(); mutex.unlock();
ao_plugin_send_tag(this, chunk->tag); ao_plugin_send_tag(this, *chunk->tag);
mutex.lock(); mutex.lock();
} }

View File

@ -257,11 +257,11 @@ RecorderOutput::SendTag(const Tag &tag)
} }
static void static void
recorder_output_send_tag(AudioOutput *ao, const Tag *tag) recorder_output_send_tag(AudioOutput *ao, const Tag &tag)
{ {
RecorderOutput &recorder = *(RecorderOutput *)ao; RecorderOutput &recorder = *(RecorderOutput *)ao;
recorder.SendTag(*tag); recorder.SendTag(tag);
} }
static size_t static size_t

View File

@ -407,10 +407,10 @@ RoarOutput::SendTag(const Tag &tag)
} }
static void static void
roar_send_tag(AudioOutput *ao, const Tag *meta) roar_send_tag(AudioOutput *ao, const Tag &meta)
{ {
RoarOutput *self = (RoarOutput *)ao; RoarOutput *self = (RoarOutput *)ao;
self->SendTag(*meta); self->SendTag(meta);
} }
const struct AudioOutputPlugin roar_output_plugin = { const struct AudioOutputPlugin roar_output_plugin = {

View File

@ -462,7 +462,7 @@ my_shout_pause(AudioOutput *ao)
} }
static void static void
shout_tag_to_metadata(const Tag *tag, char *dest, size_t size) shout_tag_to_metadata(const Tag &tag, char *dest, size_t size)
{ {
char artist[size]; char artist[size];
char title[size]; char title[size];
@ -470,7 +470,7 @@ shout_tag_to_metadata(const Tag *tag, char *dest, size_t size)
artist[0] = 0; artist[0] = 0;
title[0] = 0; title[0] = 0;
for (const auto &item : *tag) { for (const auto &item : tag) {
switch (item.type) { switch (item.type) {
case TAG_ARTIST: case TAG_ARTIST:
strncpy(artist, item.value, size); strncpy(artist, item.value, size);
@ -488,7 +488,7 @@ shout_tag_to_metadata(const Tag *tag, char *dest, size_t size)
} }
static void my_shout_set_tag(AudioOutput *ao, static void my_shout_set_tag(AudioOutput *ao,
const Tag *tag) const Tag &tag)
{ {
ShoutOutput *sd = (ShoutOutput *)ao; ShoutOutput *sd = (ShoutOutput *)ao;
@ -498,7 +498,7 @@ static void my_shout_set_tag(AudioOutput *ao,
Error error; Error error;
if (!encoder_pre_tag(sd->encoder, error) || if (!encoder_pre_tag(sd->encoder, error) ||
!write_page(sd, error) || !write_page(sd, error) ||
!encoder_tag(sd->encoder, tag, error)) { !encoder_tag(sd->encoder, &tag, error)) {
LogError(error); LogError(error);
return; return;
} }

View File

@ -250,7 +250,7 @@ public:
bool EncodeAndPlay(const void *chunk, size_t size, Error &error); bool EncodeAndPlay(const void *chunk, size_t size, Error &error);
void SendTag(const Tag *tag); void SendTag(const Tag &tag);
size_t Play(const void *chunk, size_t size, Error &error); size_t Play(const void *chunk, size_t size, Error &error);

View File

@ -499,10 +499,8 @@ httpd_output_pause(AudioOutput *ao)
} }
inline void inline void
HttpdOutput::SendTag(const Tag *tag) HttpdOutput::SendTag(const Tag &tag)
{ {
assert(tag != nullptr);
if (encoder->plugin.tag != nullptr) { if (encoder->plugin.tag != nullptr) {
/* embed encoder tags */ /* embed encoder tags */
@ -514,7 +512,7 @@ HttpdOutput::SendTag(const Tag *tag)
/* send the tag to the encoder - which starts a new /* send the tag to the encoder - which starts a new
stream now */ stream now */
encoder_tag(encoder, tag, IgnoreError()); encoder_tag(encoder, &tag, IgnoreError());
/* the first page generated by the encoder will now be /* the first page generated by the encoder will now be
used as the new "header" page, which is sent to all used as the new "header" page, which is sent to all
@ -538,7 +536,7 @@ HttpdOutput::SendTag(const Tag *tag)
TAG_NUM_OF_ITEM_TYPES TAG_NUM_OF_ITEM_TYPES
}; };
metadata = icy_server_metadata_page(*tag, &types[0]); metadata = icy_server_metadata_page(tag, &types[0]);
if (metadata != nullptr) { if (metadata != nullptr) {
const ScopeLock protect(mutex); const ScopeLock protect(mutex);
for (auto &client : clients) for (auto &client : clients)
@ -548,7 +546,7 @@ HttpdOutput::SendTag(const Tag *tag)
} }
static void static void
httpd_output_tag(AudioOutput *ao, const Tag *tag) httpd_output_tag(AudioOutput *ao, const Tag &tag)
{ {
HttpdOutput *httpd = HttpdOutput::Cast(ao); HttpdOutput *httpd = HttpdOutput::Cast(ao);